package cn.iinda.electronicInfo;

import com.alibaba.fastjson.serializer.SerializerFeature;
import com.alibaba.fastjson.support.config.FastJsonConfig;
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.web.HttpMessageConverters;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@SpringBootApplication
//@EnableEurekaClient
@EnableSwagger2
@MapperScan("cn.iinda.electronicInfo.dao")//将项目中对应的mapper类的路径加进来就可以了
public class ElectronicInfoApplication {

	public static void main(String[] args) {
		SpringApplication.run(ElectronicInfoApplication.class, args);
	}

	/**
	 * Bean配置管理
	 * Created by surpass.wei@gmail.com on 2017/2/21.
	 */

	@Configuration
	public class BeanConfig {

		/*注入Bean : HttpMessageConverters，以支持fastjson*/
		@Bean
		public HttpMessageConverters fastJsonHttpMessageConverters() {
			FastJsonHttpMessageConverter fastConvert = new FastJsonHttpMessageConverter();
			FastJsonConfig fastJsonConfig = new FastJsonConfig();
			fastJsonConfig.setSerializerFeatures(SerializerFeature.PrettyFormat);
			fastConvert.setFastJsonConfig(fastJsonConfig);
			return new HttpMessageConverters((HttpMessageConverter<?>) fastConvert);
		}
	}

}
